/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author lomanda
 */
@Entity
@Table(name = "itemEncomenda")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ItemEncomenda.findAll", query = "SELECT i FROM ItemEncomenda i"),
    @NamedQuery(name = "ItemEncomenda.findByIdItemEncomenda", query = "SELECT i FROM ItemEncomenda i WHERE i.idItemEncomenda = :idItemEncomenda"),
    @NamedQuery(name = "ItemEncomenda.findByQuantidade", query = "SELECT i FROM ItemEncomenda i WHERE i.quantidade = :quantidade")})
public class ItemEncomenda implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idItemEncomenda")
    private Integer idItemEncomenda;
    @Column(name = "quantidade")
    private Integer quantidade;
    @JoinColumn(name = "fkEncomenda", referencedColumnName = "idEncomenda")
    @ManyToOne(optional = false)
    private Encomenda fkEncomenda;
    @JoinColumn(name = "fkMaterial", referencedColumnName = "idMaterial")
    @ManyToOne(optional = false)
    private Material fkMaterial;

    public ItemEncomenda() {
    }

    public ItemEncomenda(Integer idItemEncomenda) {
        this.idItemEncomenda = idItemEncomenda;
    }

    public Integer getIdItemEncomenda() {
        return idItemEncomenda;
    }

    public void setIdItemEncomenda(Integer idItemEncomenda) {
        this.idItemEncomenda = idItemEncomenda;
    }

    public Integer getQuantidade() {
        return quantidade;
    }

    public void setQuantidade(Integer quantidade) {
        this.quantidade = quantidade;
    }

    public Encomenda getFkEncomenda() {
        return fkEncomenda;
    }

    public void setFkEncomenda(Encomenda fkEncomenda) {
        this.fkEncomenda = fkEncomenda;
    }

    public Material getFkMaterial() {
        return fkMaterial;
    }

    public void setFkMaterial(Material fkMaterial) {
        this.fkMaterial = fkMaterial;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idItemEncomenda != null ? idItemEncomenda.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ItemEncomenda)) {
            return false;
        }
        ItemEncomenda other = (ItemEncomenda) object;
        if ((this.idItemEncomenda == null && other.idItemEncomenda != null) || (this.idItemEncomenda != null && !this.idItemEncomenda.equals(other.idItemEncomenda))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.ItemEncomenda[ idItemEncomenda=" + idItemEncomenda + " ]";
    }
    
}
